<template>
    <div class="bg-white grid-content">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">

        <el-form-item label="字段名称">
          <el-select v-model="formInline.label" placeholder="请选择字段名称">
            <el-option
            v-for="item in options"
            :key="item.label"
            :label="item.name"
            :value="item.label">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="">
          <el-input v-model="formInline.value" placeholder="请输入字段值"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"  @click="emitSubmit">查询</el-button>
        </el-form-item>

      </el-form>
    </div>
</template>
<script>
import sjzdApi from '@/api/sjtb/generalquery';

export default {
   props: ["zdname"],
   data() {
      return {
        formInline:{
            label:'',
            value:'',
        },
        options:[],
      }
   },
   created(){
   },
   mounted(){
    this.search();
   },
   computed:{
   },
   methods:{
    async search() {
      //发送查询请求
      let res = await sjzdApi.getList({parentName:this.zdname});
      //判断是否成功
      if(res.success){
        console.log(res.data);
        console.log(this.zdname);
        this.options = res.data;
      }
    },
    //触发父组件的方法
    emitSubmit(){
        this.$emit('onEmitSearch', this.formInline)
    }
   },
}
</script>
<style lang="scss" scoped>
.bg-white {
  background: #ffffff;
}

.grid-content {
  padding: 0px 10px 0px 10px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.el-form-item {
  margin: 15px 10px 15px 10px;
}

</style>
